

import java.util.Arrays;

import org.junit.*;

public class SetTest {
	private Set set;
	@Before
	public void setUp(){
		set = new Set();
	}
	@Test
	public void testInsert(){		
		set.insert(5);
		int[] temp = {5};
		Assert.assertTrue(Arrays.equals(set.toArray(), temp));
		
		set.insert(6);
		int[] temp0 = {5,6};
		Assert.assertTrue(Arrays.equals(set.toArray(), temp0));
		
		set.insert(4);
		int[] temp1 = {4,5,6};
		Assert.assertTrue(Arrays.equals(set.toArray(), temp1));
		
		set.insert(5);
		int[] temp2 = {4,5,6};
		Assert.assertTrue(Arrays.equals(set.toArray(), temp2));
	}
	
	@Test
	public void testMember(){
		set.insert(22);
		set.insert(19);
		set.insert(33);
		
		Assert.assertFalse(set.member(45));
		Assert.assertFalse(set.member(25));
		Assert.assertTrue(set.member(22));
		
	}
	
	@Test
	public void testSection(){
		Set secondSet = new Set();
		
		set.insert(10);
		set.insert(11);//added this later because we found a bug in Set(which we now cover)
		set.insert(15);
		set.insert(22);
		
		secondSet.insert(10);
		secondSet.insert(11);//added this later because we found a bug in Set
		secondSet.insert(13);
		secondSet.insert(20);
		
		//This should remove 10 from secondSet
		secondSet.section(set);
		
		int[] compareArray = {13,20}; 
		Assert.assertTrue(Arrays.equals(secondSet.toArray(), compareArray));
	}
	
	@Test
	public void testContainsArithTriple(){
		set.insert(10);
		set.insert(34);
		Assert.assertFalse(set.containsArithTriple());
		set.insert(22);
		Assert.assertTrue(set.containsArithTriple());
	}
}
